/*=========================================================================
The Impact of Denying a Wanted Abortion on Women and Children
Authors: Juliana Londoño-Vélez and Estefanía Saravia

Creation date: January 9th, 2024
--------------------------------------------------------------------------
Figure 1 - Female Judges are 20 p.p. Less Likel to Deny Women a Wanted Abortion
=========================================================================*/


use "$data/Final_Tutelas_Medellin.dta", replace

keep if Juez_Aborto==1

foreach tipo in Aborto  {
egen Numero_`tipo' = nvals(id_caso) if Caso_`tipo' ==1, by(id_juez)

egen Casos_`tipo' = max(Numero_`tipo'), by(id_juez)
drop Numero_`tipo'

egen Numero_`tipo' = sum(Niega) if Caso_`tipo' ==1, by(id_juez)
egen Niega_`tipo' = max(Numero_`tipo'), by(id_juez)
drop Numero_`tipo'

replace Casos_`tipo'=0 if Casos_`tipo'==.
replace Niega_`tipo'=0 if Niega_`tipo'==.

gen Share_`tipo'=Niega_`tipo'/Casos_`tipo'

}


collapse (firstnm) Share_Aborto Casos_Aborto, by(id_juez Mujer_Ponente)


twoway histogram Share_Aborto if Mujer_Ponente ==1 [fw=Casos_Aborto], percent bcolor(pink%70) barw(0.02) bin(40) || histogram Share_Aborto if Mujer_Ponente ==0 [fw=Casos_Aborto], percent bcolor(blue%25) barw(0.02) bin(40) legend(order(1 "Female" 2 "Male") ring(0) rows(1) position(11) bmargin(large) size(small))  ytitle(Percentage) xtitle(Average rejection rate of abortion rights {it:tutelas}) xsize(8) ysc(r(0 25)) ylab(0(10)50)


